import { ApiVersoin, ConfigEnum, ContentTypeEnum, MicroServiceEnum } from '@/common/enums/httpEnum'

const Url = {
  requestExample1: `/config/get`, // PC
  requestExample2: `/safety-inspect-rule/parent-list`, // 网关
  requestExample3: `/agreement/display`, // C
  requestExample4: `${ApiVersoin.v3}/qy-user/anti-get-phone-code`, // B
  uploadFile: `/uploads/handle`,
  uploadImg: `/upload/upload-img`,

  getSmsVerCode: '/site/get-phone-code',
  getImgVerifyCode: '/common/sendCode',
  passwordCode: `/customer/send-change-lock-password-code`,
  verificationCode: `${ApiVersoin.V4}/user/send-mobile-verification-code`,
  getSignedUrl: '/upload/signed-url',
  geocoderUrl: MAP.serveUrl,
  getPrivacy: `/privacy/get-privacy`,
}

/**
 * @description: 请求示例
 */
export const RequestExample1 = () => uni.$uv.http.get(Url.requestExample1, { header: { 'Content-Type': ContentTypeEnum.JSON }, custom: {} })

export const RequestExample2 = (params) =>
  uni.$uv.http.get(Url.requestExample2, { params, header: { [ConfigEnum.MICRO_SERVICE_PLATFORM]: MicroServiceEnum.VANKEYI_MASTER, 'Content-Type': ContentTypeEnum.FORM_DATA } })

export const RequestExample3 = (params) => uni.$uv.http.get(Url.requestExample3, { params, header: { [ConfigEnum.APP_PLAT]: MicroServiceEnum.MINI } })

export const RequestExample4 = (params) =>
  uni.$uv.http.post(Url.requestExample4, params, { header: { [ConfigEnum.MICRO_SERVICE_PLATFORM]: MicroServiceEnum.QYHYBRID }, custom: {} })

/**
 * @description: 上传图片或者视频
 */
export const fileUpload = (params) => uni.$uv.http.upload(Url.uploadFile, { ...params, custom: { showLoading: true, loadingMsg: '上传中' } })

/**
 * @description: 获取短信验证码
 */
export const getSmsVerifyCode = (params) => uni.$uv.http.post(Url.getSmsVerCode, params, { custom: { showLoading: true, loadingMsg: '发送中', showMessage: true } })
/**
 * @description: 获取图形验证码
 */
export const getImgVerifyCode = (params) => uni.$uv.http.post(Url.getImgVerifyCode, params, { custom: { showLoading: true } })

/**
 * @description: 逆地址解析（坐标解析位置描述）
 * @腾讯 https://lbs.qq.com/service/webService/webServiceGuide/address/Gcoder
 * @百度 https://lbs.baidu.com/faq/api?title=webapi/guide/webservice-geocoding-abroad-base
 * @高德 https://lbs.amap.com/api/webservice/guide/api/georegeo#t5
 */
export const getMapGeocoder = (params) => uni.$uv.http.get(Url.geocoderUrl, { params })

// 上传身份证
export const uploadImg = (data) => uni.$uv.http.upload(`${Url.uploadImg}`, data, { header: { 'Content-type': ContentTypeEnum.FORM_DATA } })

/*
 *获取更改门锁验证码（需要修改）
 */
export const passwordCode = (params) => uni.$uv.http.get(Url.passwordCode, { params, custom: { showLoading: true } })

export const verificationCode = (data) => uni.$uv.http.post(Url.verificationCode, data, { custom: { showLoading: true } })
export const getSignedUrl = (params) => uni.$uv.http.get(Url.getSignedUrl, { params, custom: { showLoading: true } })

export const getPrivacy = (params) => uni.$uv.http.get(Url.getPrivacy, { params, custom: { showLoading: true } })
